<template>
  <div id="app" class="clearfix">
    <!-- 主题页面（都有左侧菜单的页面） -->
    <div v-if="$route.meta.keepAlive" class="appInner">
      <!-- 左侧通用菜单 -->
      <Slide></Slide>
      <!-- 右侧主体内容 -->
      <transition name="fade" mode="out-in">
        <router-view></router-view>
      </transition>
    </div>
    <!-- 登录页 -->
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>

<script>
import Slide from "@/components/slide/slide";
export default {
  name: "App",
  components: {
    Slide
  },
  created: function() {
    //在页面加载时读取sessionStorage里的状态信息
    sessionStorage.getItem("userMsg") &&
      this.$store.replaceState(
        Object.assign(
          this.$store.state,
          JSON.parse(sessionStorage.getItem("userMsg"))
        )
      );
    ////在页面刷新时将vuex里的信息保存到sessionStorage里
    window.addEventListener("unload", () => {
      sessionStorage.setItem("userMsg", JSON.stringify(this.$store.state));
    });
  },
  methods: {
    
  }
};
</script>

<style scoped>
#app {
  width: 100%;
  height: 100%;
}
.appInner {
  overflow: hidden;
  display: flex;
}
</style>
